<%@ page contentType="text/html; charset=UTF-8" %>
<%@ include file="/WEB-INF/jspf/taglibs.jspf"%>
<html>
<head>
  <script type="text/javascript">
    localPath="dashboard"
  </script>
  <link rel="stylesheet" type="text/css" media="all" href="/js/daterangepicker/daterangepicker.css" />
  <script type="text/javascript" src="http://netdna.bootstrapcdn.com/bootstrap/3.3.2/js/bootstrap.min.js"></script>
  <script type="text/javascript" src="/js/daterangepicker/moment.js"></script>
  <script type="text/javascript" src="/js/daterangepicker/daterangepicker.js"></script>
</head>
<body>
<div class="p-h-md p-v bg-white box-shadow pos-rlt">
    <h3 class="no-margin have-btn-title">概况总览</h3>
</div>
<div class="p-md ng-scope">
  <div class="row">
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          现金账户
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm ng-scope" >
      <button onclick="getdialog()" type="button" class="btn btn-sm btn-success ng-click-active pull-right ng-scope money-item-btn" style="margin:20px 0 0 0" data-toggle="modal"
      				data-placement="top" data-animation="am-slide-top aside-open-backdrop" data-container="body" >
      <i class="glyphicon glyphicon-plus"></i>
        充值
      </button>
<input id="payOfLinkman" type="hidden" value="${member.payOfLinkman }">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
                <div class="text-white"><i class="fa fa-cny"></i></div>
            </div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold">
            <c:if test="${! empty form.balance }">
            <c:choose>
            <c:when test="${userContext.fromBackend ==true &&system==false }">
            ￥
            </c:when>
            <c:otherwise>
             ￥<fmt:formatNumber value="${form.balance }" maxFractionDigits="2" />
            </c:otherwise>
            </c:choose>
            </c:if>
            </div>
            <small class="text-muted" id="date">
            截止<fmt:formatDate value="${form.balanceAt }"  pattern="yyyy-MM-dd"/>
            </small>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          虚拟账户
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
                <div class="text-white"><i class="ti-credit-card"></i></div>
            <canvas width="65" height="65"></canvas></div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold">-</div>
                <small class="text-muted" >
                截止<fmt:formatDate value="${form.balanceAt }"  pattern="yyyy-MM-dd"/>
            </small>
          </div>
        </div>
      </div>
    </div>
    <div class="col-sm-4">
      <div class="panel b-light">
        <div class="panel-heading p-v-xs p-h-sm">
          当前广告数
        </div>
        <div class="progress progress-xxxs no-margin no-radius bg-white">
          <div class="progress-bar bg-light" style="width:100%"></div>
        </div>
        <div class="panel-body p-sm">
          <div class="pull-left pull-none-sm text-center m-r-xs">
            <div class="easyPieChart">
                <div class="text-white"><i class="ti-menu"></i></div>
            <canvas width="65" height="65"></canvas></div></div>
          <div class="goDown clear money-item-style">
            <div class="text-2x font-bold" id="count"> ${form.adNum }</div>
              <small class="text-muted" id="update">截止<fmt:formatDate value="${form.balanceAt }"  pattern="yyyy-MM-dd"/></small>
          </div>
        </div>
      </div>
    </div>
  </div>
  <div class="panel b-light">
      <div class="panel-heading clear">
          <div class="col-md-2 pull-right time-config">
              <input type="text" id="config-demo" class="form-control">
              <i class="glyphicon glyphicon-calendar fa fa-calendar"></i>
          </div>
        <span>总体情况</span>
     </div>
    <div id="dashboardContent" class="row" >
    </div>
  </div>
  <!-- 默认搜索日期  -->
<c:if test="${userContext.member.operationType==1}">
  <input type="hidden" name="timeType"  id="timeType" value="3" />
</c:if>
<c:if test="${userContext.member.operationType==2}">
  <input type="hidden" name="timeType"  id="timeType" value="1" />
</c:if>
<script type="text/javascript">

    var index = '1';

    $('#config-demo').daterangepicker({
        dateFormat: 'yy-mm-dd',
        "ranges": {
            "今天": [moment().startOf('day'), moment()],
            "昨天": [moment().subtract('days', 1).startOf('day'), moment().subtract('days', 1).endOf('day')],
            "过去7天": [moment().subtract('days', 6), moment()],
            "过去30天": [moment().subtract('days', 29), moment()]
        },
        opens : 'left', //日期选择框的弹出位置
        applyClass : 'btn-small btn-primary blue',
        cancelClass: 'cancel-btn-style',
        maxDate: new Date(),
        // showCustomRangeLabel: false,
        locale : {
            applyLabel : '确定',
            cancelLabel : '取消',
            customRangeLabel : '自定义',
            daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
            monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',
                       '七月', '八月', '九月', '十月', '十一月', '十二月' ],
            firstDay : 1,
            format : 'YYYY-MM-DD',
        },
    }, function(start, end, label) {

        switch(label)
        {
        case "今天":
          index = 1;
          break;
        case "昨天":
          index = 2;
          break;
        case "过去7天":
          index = 3;
          break;
        case "过去30天":
          index = 4;
          break;
       case "自定义":
          index = 5;
          break;
        }
        handleDashboard(index,start.format('YYYY-MM-DD'), end.format('YYYY-MM-DD'));
    });


//权限控制
if(!isFromBackend||system==true){
  	function handleDashboard(timeType,start,end){
        var URL="/dashboard/data?timeType=" + timeType +"&c="+ new Date().getTime();
        //自定义
        if(index=="5"){
            URL=URL+"&startDate="+start+"&endDate="+end;
        }
  		$.ajax({
  			url: URL,
  			success: function(res){
          console.log($("#dashboardContent").length);
  				$("#dashboardContent").html(res);
  			}
  		});
  	};
		var timeType = $("#timeType").val()

		handleDashboard(timeType)
}

function getdialog(){
	bootbox.dialog({
		//size:'large',
		 message: '<div class="modal-body"><p>充值联系人</p><p>'+$("#payOfLinkman").val()+'</p></div>',
	      title: "充值信息",
	});
	
}

</script>
</body></html>
